#!/bin/bash

echo '///------------'
echo '/// 清理项目中...  '
echo '///------------'
echo ''
chmod +x ./gradlew
./gradlew clean
if [ $? -ne 0 ];then
    echo "Error while cleaning $project_name"
    exit -1
fi

echo '///------------'
echo '/// 编译工程中...  '
echo '///------------'
echo ''
./gradlew :app:assembleDebug --info
if [ $? -ne 0 ];then
    echo "Error while building $project_name"
    exit -1
fi

#时间
time=$(date "+%Y_%m_%d")
description=${time}
echo $description
#build文件夹路径
build_path=${project_path}/app/build/outputs/apk/${buildType}/${target}/${project_name}_${target}.apk


#上传到pgyer
api_key="1cdad4511eaaafc93a2b0555fc8b8e9f"
password="tange"
echo '///-------------'
echo '/// 上传中 '
echo '///-------------'
curl -F "file=@"${build_path} -F "buildPassword="${password} -F "buildUpdateDescription="${description} -F "buildInstallType=2" -F "_api_key="${api_key} https://www.pgyer.com/apiv2/app/upload
echo '///-------------'
echo '/// 发布完成 '
echo '///-------------'


exit 0

